<!DOCTYPE html>
<html lang="en" ng-app="SubmitQueueModule" ng-controller="SQCntl as cntl">

<head>
  <link rel="stylesheet" href="https://cdn.gitcdn.link/cdn/angular/bower-material/v1.0.7/angular-material.min.css" type="text/css">
  <link rel="stylesheet" href="md-data-table.min.css" type="text/css">
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=RobotoDraft:300,400,500,700,400italic" type="text/css">
  <link rel="stylesheet" href="style.css" type="text/css">
  <link rel="shortcut icon" href="https://raw.githubusercontent.com/kubernetes/kubernetes/master/logo/logo.png">
  <meta name="viewport" content="initial-scale=1">

  <title ng-bind-template="{{cntl.metadata.ProjectName}} Submit Queue">Submit Queue</title>

</head>

<body>
  <!-- Indent the whole thing -->
  <md-content class="md-padding" layout="column">
    <!-- Display the white border around the indented portion -->
    <md-content class="md-whiteframe-z2">
      <md-toolbar layout="row" layout-align="space-around center">
        <h1 class="md-display-2">{{cntl.metadata.ProjectName}} Submit Queue Status</h1>
        <a ng-href="https://k8s.io"><img src="https://raw.githubusercontent.com/kubernetes/kubernetes/master/logo/logo.png" alt="kubernetes logo" class="titleLogo"></a>
      </md-toolbar>
      <md-toolbar class="md-warn md-hue-1" ng-show="cntl.testResults.yellowBuilds">
        <h2 class="md-toolbar-tools">E2E Tests Are Troubled But Not Failing</h2>
      </md-toolbar>
      <md-toolbar class="md-warn" ng-show="cntl.testResults.redBuilds">
        <h2 class="md-toolbar-tools">E2E Tests Failing. Entire submit queue blocked. Last merge&nbsp;<span am-time-ago="cntl.lastMergeTime"></span>.</h2>
      </md-toolbar>
      <md-content class="md-padding">
        <md-tabs md-selected="cntl.selected" md-dynamic-height md-border-bottom>

          <md-tab label="PRs" md-on-select="cntl.selectTab('prs')">
            <md-content class="md-whiteframe-z2">
              <md-toolbar>
                <h2 class="md-toolbar-tools">Pull Requests ({{cntl.prsCount}})</h2>
              </md-toolbar>
              <form ng-submit="$event.preventDefault()">
                <md-autocomplete md-selected-item="cntl.prSelectedItem" md-search-text="cntl.prDisplayValue" md-items="item in cntl.prQuerySearch(cntl.prDisplayValue)" md-item-text="item.display" md-min-length="0" placeholder="Enter username or PR number">
                  <md-item-template>
                    <span md-highlight-text="cntl.prDisplayValue" md-highlight-flags="^i">{{item.display}}</span>
                  </md-item-template>
                  <md-not-found>
                    No matches found for "{{cntl.prDisplayValue}}".
                  </md-not-found>
                </md-autocomplete>
              </form>
            </md-content>
            <md-list>
              <md-list-item class="md-3-line" ng-repeat="pr in cntl.prs | loginOrPR:cntl.prDisplayValue | orderBy:'Number' track by pr.Number">
                <a class="md-avatar" ng-href="{{cntl.metadata.RepoPullUrl}}{{pr.Login}}">
                  <img ng-src="{{pr.AvatarURL}}" alt="{{pr.Login}}">
                </a>
                <md-content class="md-list-item-text" layout="column">
                  <h3 class="md-body-1">
                    <a ng-href="{{pr.URL}}">#{{pr.Number}}: {{pr.Title}}</a>
                  </h3>
                  <h4 class="md-body-2">{{pr.Reason}}</h4>
                  <p>{{pr.Time | date:'medium'}} (<span style="color: green">+{{pr.Additions}}</span>/<span style="color: red">-{{pr.Deletions}}</span>)</p>
                </md-content>
                <md-divider md-inset ng-if="!$last"></md-divider>
              </md-list-item>
            </md-list>
          </md-tab>

          <md-tab label="Queue" md-on-select="cntl.selectTab('queue')">
            <md-content class="md-whiteframe-z2">
              <md-toolbar class="md-whiteframe-z2">
                <h2 class="md-toolbar-tools">Queued For Retest And Merge ({{cntl.e2equeue.length}})</h2>
              </md-toolbar>
              <md-subheader class="md-primary">Estimated Merging {{cntl.sqStats.MergeRate}} PRs per day.</md-subheader>
            </md-content>
            <md-divider></md-divider>
            <section>
              <md-subheader class="md-primary">CURRENTLY RUNNING</md-subheader>
              <md-list layout-padding>
                <md-list-item class="md-2-line" ng-repeat="pr in cntl.e2erunning track by pr.Number">
                  <a class="md-avatar" ng-href="{{cntl.metadata.RepoPullUrl}}{{pr.Login}}">
                    <img ng-src="{{pr.AvatarURL}}" alt="{{pr.Login}}">
                  </a>
                  <md-content class="md-list-item-text" layout="column">
                    <h3 class="md-body-1">
                      <a ng-href="{{pr.URL}}">#{{pr.Number}}: {{pr.Title}}</a> (<span style="color: green">+{{pr.Additions}}</span>/<span style="color: red">-{{pr.Deletions}}</span>)
                    </h3>
                    <h4 class="md-body-2">
                      {{pr.ExtraInfo}}
                    </h4>
                  </md-content>
                </md-list-item>
              </md-list>
            </section>

            <section ng-if="cntl.batch.Running">
              <md-subheader class="md-primary">CURRENTLY RUNNING BATCH</md-subheader>
              <md-content layout-padding>
                <div class="md-body-1" layout-padding>
                  <a href="http://prow.k8s.io/?refs={{cntl.batch.Running.refs | refToShortRef}}">{{(cntl.batch.Running.refs | refToPRs).join(" ")}}</a>
                </div>
              </md-content>
            </section>

            <section>
              <md-subheader class="md-primary">QUEUE</md-subheader>
              <md-list layout-padding>
                <md-list-item class="md-2-line" ng-repeat="pr in cntl.e2equeue track by pr.Number">
                  <a class="md-avatar" ng-href="{{cntl.metadata.RepoPullUrl}}{{pr.Login}}">
                    <img ng-src="{{pr.AvatarURL}}" alt="{{pr.Login}}">
                  </a>
                  <md-content class="md-list-item-text" layout="column">
                    <h3 class="md-body-1">
                      <a ng-href="{{pr.URL}}">#{{pr.Number}}: {{pr.Title}}</a> (<span style="color: green">+{{pr.Additions}}</span>/<span style="color: red">-{{pr.Deletions}}</span>)
                    </h3>
                    <h4 class="md-body-2">
                      {{pr.ExtraInfo}}
                    </h4>
                  </md-content>
                  <md-divider md-inset ng-if="!$last"></md-divider>
                </md-list-item>
              </md-list>
            </section>
          </md-tab>

          <md-tab label="History" md-on-select="cntl.selectTab('history')">
            <md-content class="md-whiteframe-z2">
              <md-toolbar>
                <h2 class="md-toolbar-tools">Historic Merge Bot Decisions</h2>
                <form ng-submit="$event.preventDefault()">
                  <md-autocomplete md-selected-item="cntl.historySelectedItem" md-search-text="cntl.historyDisplayValue" md-items="item in cntl.historyQuerySearch(cntl.historyDisplayValue)" md-item-text="item.display" md-min-length="0" placeholder="Enter username or PR number">
                    <md-item-template>
                      <span md-highlight-text="cntl.historyDisplayValue" md-highlight-flags="^i">{{item.display}}</span>
                    </md-item-template>
                    <md-not-found>
                      No matches found for "{{cntl.historyDisplayValue}}".
                    </md-not-found>
                  </md-autocomplete>
                </form>
              </md-toolbar>
            </md-content>
            <md-list>
              <md-list-item class="md-3-line" ng-repeat="pr in cntl.historyPRs | loginOrPR:cntl.historyDisplayValue | orderBy: '-Time' track by pr.Time">
                <a class="md-avatar" ng-href="{{cntl.metadata.RepoPullUrl}}{{pr.Login}}">
                  <img ng-src="{{pr.AvatarURL}}" alt="{{pr.Login}}">
                </a>
                <md-content class="md-list-item-text" layout="column">
                  <h3 class="md-body-1">
                    <a ng-href="{{pr.URL}}">#{{pr.Number}}: {{pr.Title}}</a>
                  </h3>
                  <h4 class="md-body-2">{{pr.Reason}}</h4>
                  <p class="md-body-3">{{pr.Time | date:'medium'}}</p>
                </md-content>
                <md-divider md-inset ng-if="!$last"></md-divider>
              </md-list-item>
            </md-list>
          </md-tab>

          <md-tab md-on-select="cntl.selectTab('e2e')">
            <md-tab-label>
              <span ng-class="{'redTab':cntl.testResults.redBuilds , 'yellowTab':cntl.testResults.yellowBuilds}">E2E Tests</span>
            </md-tab-label>
            <md-tab-body>
              <md-toolbar class="md-whiteframe-z2">
                <h2 class="md-toolbar-tools">End-to-End Results</h2>
              </md-toolbar>
              <h2 class="md-title" ng-show="cntl.testResults.blockingBuilds.length > 0">Queue-Blocking Builds</h2>
              <md-chips ng-model="cntl.testResults.blockingBuilds" readonly="true">
                <md-chip-template title="{{$chip.msg}}">
                  <span style="color: {{$chip.color}}">{{$chip.state}}</span> <a ng-href="http://ci-test.k8s.io/{{$chip.name}}/{{$chip.id}}/">{{$chip.name}}</a>
                  <span style="color: {{$chip.color}}">{{$chip.msg}}</span> <span title="Job stability">{{$chip.stability}}</span>
                </md-chip-template>
              </md-chips>
              <h2 class="md-title" ng-show="cntl.testResults.nonBlockingBuilds.length > 0">Non-Queue-Blocking Builds</h2>
              <md-chips ng-model="cntl.testResults.nonBlockingBuilds" readonly="true">
                <md-chip-template title="{{$chip.msg}}">
                  <span style="color: {{$chip.color}}">{{$chip.state}}</span> <a ng-href="http://ci-test.k8s.io/{{$chip.name}}/{{$chip.id}}/">{{$chip.name}}</a>
                  <span style="color: {{$chip.color}}">{{$chip.msg}}</span>
                </md-chip-template>
              </md-chips>
              <br>
              <br>
              <h2 class="md-title" ng-show="cntl.OverallHealth.length > 0">Overall Health: {{ cntl.OverallHealth }}</h2>
              <p>Health percents are the fraction of the time that a given job is stable for the last day, or since the submit queue restarted ({{ cntl.sqStats.StartTime | date:'medium'}})</span>, whichever is shorter. The <a ng-href="{{cntl.metadata.HistoryUrl}}"><strong>24-Hour Test Report</strong></a> shows more detail, along with a list of flaky and broken tests in merge-blocking jobs.
              </p>
              <p>
                <img ng-src="{{cntl.metadata.ChartUrl}}" style="max-width: 100%"/>
              </p>
            </md-tab-body>
          </md-tab>

          <md-tab label="Info" md-on-select="cntl.selectTab('info')">
            <md-content class="md-padding">
              <md-tabs md-dynamic-height md-border-bottom>

                <md-tab label="Queue Order">
                  <md-toolbar class="md-whiteframe-z2">
                    <h2 class="md-toolbar-tools">How PRs get ordered in the queue</h2>
                  </md-toolbar>
                  <md-content class="md-padding">
                    <span id="priority-info"></span>
                  </md-content>
                </md-tab>

                <md-tab label="Merge Requirements">
                  <md-toolbar class="md-whiteframe-z2">
                    <h2 class="md-toolbar-tools">Requirements for a PR to get automatically merged </h2>
                  </md-toolbar>
                  <md-content class="md-padding">
                    <span id="merge-info"></span>
                  </md-content>
                </md-tab>

                <md-tab label="Bot Stats">
                  <md-content class="md-whiteframe-z2">
                    <md-toolbar>
                      <h2 class="md-toolbar-tools">Statistics About the Bot</h2>
                    </md-toolbar>
                  </md-content>
                  <br>
                  <h3 class=md-title>Bot Started: {{ cntl.sqStats.StartTime | date:'medium' }}</h3>
                  <h3 class=md-title>Next Sync Loop: {{ cntl.botStats.NextLoopTime | date:'medium' }}</h3>
                  <h3 class=md-title>API Calls Per Second: {{ cntl.botStats.APIPerSec }}</h3>
                  <h3 class=md-title>Github Rate Limit Count: {{ cntl.botStats.LimitRemaining }}</h3>
                  <h3 class=md-title>Github Rate Limit Next Reset: {{ cntl.botStats.LimitResetTime | date:'medium' }}</h3>
                  <h3 class=md-title>Retests avoided because of e2e test flakes: {{ cntl.sqStats.RetestsAvoided }}</h3>
                  <h3 class=md-title>Flakes ignored: {{ cntl.sqStats.FlakesIgnored }}</h3>
                  <md-content class="md-whiteframe-z2">
                    <md-data-table-container>
                      <md-data-table-toolbar>
                        <h2 class="md-title">API Calls During Last Loop</h2>
                      </md-data-table-toolbar>
                      <table md-data-table class="md-primary">
                        <thead md-order="cntl.StatOrder">
                          <tr>
                            <th order-by="$key" name="Call"></th>
                            <th order-by="Count" name="Count ({{ cntl.botStats.APICount }})" numeric descend-first></th>
                            <th order-by="CachedCount" name="Cached Count ({{ cntl.botStats.CachedAPICount }})" numeric descend-first></th>
                            <th order-by="UncachedCount" name="Uncached Count ({{ cntl.botStats.UncachedAPICount }})" numeric descend-first></th>
                          </tr>
                        </thead>
                        <tbody>
                          <tr ng-repeat="stat in cntl.botStats.Analytics | toArray | orderBy: cntl.StatOrder track by stat.$key">
                            <td>{{stat.$key}}</td>
                            <td>{{stat.Count}}</td>
                            <td>{{stat.CachedCount}}</td>
                            <td>{{stat.UncachedCount}}</td>
                          </tr>
                        </tbody>
                      </table>
                    </md-data-table-container>
                  </md-content>
                </md-tab>

                <md-tab label="Health">
                  <md-toolbar class="md-whiteframe-z2">
                    <h2 class="md-toolbar-tools">Health chart for the past week</h2>
                  </md-toolbar>
                  <md-content class="md-padding">
                    <span><img ng-src="{{cntl.metadata.ChartUrl}}" style="max-width: 100%"/></span>
                  </md-content>
                </md-tab>

                <md-tab label="Bot Commands">
                    <h1>Communicating with the Bot</h1>

                Github contributors and reviewers can communicate with the mungebot by commenting on a PR with the
                  following commands entered alone in the text field. All commands require the following syntax:
                  <br><br> /Command [Optional Args]. <br><br> Note the forward slashing preceding the command name.
                    <h2>List of Commands</h2>

                    <ol>
                      <li>lgtm: applies the lgtm label</li>
                      <li>lgtm cancel: removes a previously applied lgtm label</li>
                      <li>approve: approve all the files for which you are an approver</li>
                      <li>approve cancel: removes your approval on this pull-request</li>
                    </ol>

                </md-tab>
              </md-tabs>
            </md-content>
          </md-tab>

        </md-tabs>
      </md-content>
    </md-content>
  </md-content>
  <!-- Angular Material Dependencies -->
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js" type="text/javascript"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-animate.min.js" type="text/javascript"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-aria.min.js" type="text/javascript"></script>
  <!--
  Local copy of angular-material.js with the fix in https://github.com/angular/material/issues/5681 applied.
  This makes rendering the PR tab ~2X faster.
  -->
  <script src="angular-material.js" type="text/javascript"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.12.0/moment.min.js" type="text/javascript"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-moment/1.0.0-beta.5/angular-moment.min.js" type="text/javascript"></script>
  <script src="md-data-table.min.js" type="text/javascript"></script>
  <script src="toArrayFilter.js" type="text/javascript"></script>
  <script src="script.js" type="text/javascript"></script>
</body>

</html>
